package com.gpf.marketing.controller;


import com.gpf.marketing.pojo.entity.AdvManage;
import com.gpf.marketing.pojo.vo.AdvMaVo;
import com.gpf.marketing.pojo.vo.AdvPoVo;
import com.gpf.marketing.service.AdvManageService;
import com.gpf.marketing.utils.OSSUtil;
import com.seventh.common.pojo.R;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @program: clms-fifth
 * @description: 广告管理的控制层
 * @author: 龚鹏飞
 * @create: 2021-07-21 19:06
 **/
@RestController
@RequestMapping("marketing/manage")
public class AdvManageController {
    @Autowired
    private AdvManageService advManageService;

//    @PostMapping("selectAdvManage/{currentPage}/{pageSize}")
//    public R selectAdvManage(@PathVariable("currentPage") Integer currentPage,
//                             @PathVariable("pageSize") Integer pageSize,
//                             @RequestBody AdvMaVo advMaVo
//                             ){
//
//        R r = advManageService.selectAdvManage(currentPage, pageSize, advMaVo);
//        System.out.println(r.getResult());
//        return r;
//    }

    @PostMapping("insertAdvManage")
    public R insertAdvManage(@RequestBody AdvManage advManage){
        return advManageService.insertAdvManage(advManage);
    }

    @PutMapping("updateAdvManage")
    public R updateAdvManage(@RequestBody AdvManage advManage){
        return advManageService.updateAdvManage(advManage);
    }
    @DeleteMapping("deleteAdvManage/{id}")
    public R deleteAdvManage(@PathVariable Integer id){
        return advManageService.deleteById(id);
    }

    @GetMapping("byId/{id}")
    public R byId(@PathVariable Integer id){
        return advManageService.selectById(id);
    }
    //名称的唯一性
    @PostMapping("selectOneName")
    public R selectOneName(@RequestBody AdvManage advManage){
        return advManageService.selectOneName(advManage);
    }

    @PutMapping("status/{id}/{status}")
    public R upStatus(@PathVariable("id") Integer id,@PathVariable("status") Integer status){
        return advManageService.upStatus(id,status);
    }
    //上传图片
    @PostMapping("upPicture")
    @ApiOperation("查询客户邮箱是否唯一")
    public String upPicture(@ApiParam("客户信息")@RequestBody MultipartFile file){
        return OSSUtil.upload2(file);
    }

    //关联查询
    @ApiModelProperty("关联查询")
    @PostMapping("findName/{currentPage}/{pageSize}")
    public R findName(@PathVariable("currentPage") Integer currentPage,
                      @PathVariable("pageSize") Integer pageSize,
                      @RequestBody  AdvMaVo advMaVo) {
        return advManageService.findName(currentPage, pageSize, advMaVo);
    }
}
